
//拿到地址栏的内容
let  a = GetRequest();
let  singerName=a["singerName"]
let name= a["name"]
let id =a["id"]
function GetRequest() {
    var url = location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for (var i = 0; i < strs.length; i++) {
            theRequest[strs[i].split("=")[0]] = decodeURIComponent(strs[i].split("=")[1]);
        }
    }
    return theRequest;
}
if (null!=a["singerName"])


{ $.get(`http://localhost:8088/dev/singer/introducti/${singerName}`,function(result){
    let arr = result.data
    console.log(arr)
    let str = `<div class="g tit">
               <h4 className = "g name" style = "display: block;font-size: 25px;float: left" >${arr.singerName}</h4>
                </div>
                <img src="../img/${arr.singerAvatar}" alt="" class="g img">
                    </div>`
    ;
    $(".tt1").html(str);

})
}
if (null==name)
{
    name=singerName
}

$(function(){
    console.log(id)
    $.get(`http://localhost:8088/dev/singer/introduction/${id}`,function(result){
        let arr = result.data
        loading(arr)

    })
    //拿到所有的歌
    $.get(`http://localhost:8088/dev/song/list/${name}`,function(result){
        let arr1 = result.data
        console.log(arr1)
        song(arr1)
    })

    function loading(arr){
    //大图

            let str = `<div class="g tit">
               <h4 className = "g name" style = "display: block;font-size: 25px;float: left" >${arr.singerName}</h4>
                </div>
                <img src="../img/${arr.singerAvatar}" alt="" class="g img">
                    </div>`
            ;
            $(".tt1").html(str);
        }
    //        table                        a标签跳转歌曲简介//
    function song(arr1){//歌曲列表
        console.log(arr1)
        // console.log(arr1[0].singerName)
            let str = `<tbody>`
            for (let i = 0; i <arr1.length; i++) {
                str += ` <tr>
                    <th scope="row">${i + 1}</th>
                    <td >
                    <a href="http://localhost:8088/dev/views/cxy/bofang.html?id=${arr1[i].id}"style="color: #333">
                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-play-circle-fill" viewBox="0 0 16 16">
                        <path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM6.79 5.093A.5.5 0 0 0 6 5.5v5a.5.5 0 0 0 .79.407l3.5-2.5a.5.5 0 0 0 0-.814l-3.5-2.5z"/>
                        </svg></a>

                     <a href="http://localhost:8088/dev/views/ccw/lyric.html?id=${arr1[i].id}&name=${arr1[i].songTitle}"style="color: #333;text-align: center">${arr1[i].songTitle}</td>
                    <td><a href="javascript:like();"style="color: #333">
                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-square" viewBox="0 0 16 16">
                  <path d="M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h12zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z"/>
                  <path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"/>
                    </svg>
                    </a>${arr1[i].clicks}</td>
                    <td>@mdo</td>
                    </tr>`
            }
            str += `</tbody>`
            $(".caption-top").html(str);

    }
})

    $(function (){
    $.ajax({
        type:'Get',
        url:'http://localhost:8088/dev/singer/select',
        // async: true,//请求是否异步，默认为异步，这也是ajax重要特性
        data: "",    //参数值
        contentType:"application/json",
        success:function(result){
            if(result.code==200){
                let arr=result.data
                // console.log(arr);
                loadData(arr)
            }
        }
    })
    //右边小照片
    let str='';
    function loadData(arr){
    for(let i=0;i<arr.length-4;i++){
    str+=` <ul  class="jjier jul"  >
                        <li class="rmgs">
                            <a href="http://localhost:8088/dev/views/czn/views/Introduction.html?id=${arr[i].id}&name=${arr[i].singerName}" title=""><img src="../avatar/${arr[i].singerAvatar}" class="rmimg"></a>
                            <div class="grma" style="margin-top: 20px">
                            <p style="font-size: 12px;"><a href="http://localhost:8088/dev/views/czn/views/Introduction.html?id=${arr[i].id}&name=${arr[i].singerName}" class="rma">${arr[i].singerName}</a></p>
                            </div>
                        </li>
                        </ul>`
}
    $(".tt").html(str);
}
})

function like(){
    alert("喜欢成功")
}